package list.impl;

/**
 * User: Vitalii Serdiuk
 * Date: 27.11.13 14:39
 */
public class Node<T> {
    private Node next;
    private T data;

    public Node(T data) {
        this.data = data;
        this.next = null;
    }

    public Node getNext() {
        return next;
    }

    public void setNext(Node next) {
        this.next = next;
    }

    public T getData() {
        return data;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Node)) return false;

        Node node = (Node) o;

        if (data != null ? !data.equals(node.data) : node.data != null) return false;
        return !(next != null ? !next.equals(node.next) : node.next != null);

    }

    @Override
    public int hashCode() {
        int result = next != null ? next.hashCode() : 0;
        result = 31 * result + (data != null ? data.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "Node{" +
                "data=" + data +
                '}';
    }
}
